package com.xwj.exception.demo.service;

import com.xwj.exception.demo.dto.StudentDTO;
import com.xwj.exception.unified.enums.BusinessEnum;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName UserService
 * @Description
 * @Author wxf
 * @Date 2022/4/18 15:37
 * @Version 1.0
 */
@Service
public class StudentService {

    public StudentDTO queryStudentById(Integer studentId) {
        StudentDTO student = getStudent(studentId);
//        BusinessEnum.NOT_EXISTS.isNotNull(student, "学员");
        BusinessEnum.STUDENT_NOT_EXISTS.isNotNull(student);
        return student;
    }

    /**
     * 模拟数据库查询学员信息
     * @param userId
     * @return
     */
    private StudentDTO getStudent(Integer userId) {
        Map<Integer, StudentDTO> map = new HashMap<>();
        map.put(1, new StudentDTO("小瓦匠", "18312345678"));
        return map.get(userId);
    }

}
